package com.starview.star.operators.system;

import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.StandardTypes;
import com.starview.platform.data.type.TypeUtils;
import com.starview.star.operators.Builtin;
import com.starview.star.operators.Intrinsics;
import com.starview.star.operators.system.runtime.SimpleLog;
import com.starview.star.operators.system.runtime.Sleep;
import com.starview.star.operators.system.runtime.SystemUtils.ClearProperty;
import com.starview.star.operators.system.runtime.SystemUtils.Exec;
import com.starview.star.operators.system.runtime.SystemUtils.Exit;
import com.starview.star.operators.system.runtime.SystemUtils.GetEnv;
import com.starview.star.operators.system.runtime.SystemUtils.GetProperties;
import com.starview.star.operators.system.runtime.SystemUtils.GetProperty;
import com.starview.star.operators.system.runtime.SystemUtils.SetProperty;
import com.starview.star.operators.system.runtime.Yield;

public class SystemUtils
{
  private static final IType stringType = StandardTypes.stringType;
  private static final IType integerType = StandardTypes.integerType;

  public static void declare(Intrinsics cxt)
  {
    cxt.declareBuiltin(new Builtin("exit", TypeUtils.procedureType(integerType), Exit.class));
    cxt.declareBuiltin(new Builtin("getenv", TypeUtils.functionType(stringType, stringType, stringType), GetEnv.class));
    cxt.declareBuiltin(new Builtin("getProperty", TypeUtils.functionType(stringType, stringType, stringType),
        GetProperty.class));
    cxt.declareBuiltin(new Builtin("setProperty", TypeUtils.procedureType(stringType, stringType), SetProperty.class));
    cxt.declareBuiltin(new Builtin("clearProperty", TypeUtils.procedureType(stringType), ClearProperty.class));
    cxt.declareBuiltin(new Builtin("getProperties", TypeUtils.functionType(TypeUtils.hashType(stringType, stringType)),
        GetProperties.class));
    cxt.declareBuiltin(new Builtin("exec", TypeUtils.functionType(stringType,
        TypeUtils.hashType(stringType, stringType), StandardTypes.integerType), Exec.class));

    cxt.declareBuiltin(new Builtin(Sleep.name, Sleep.type(), Sleep.class));
    cxt.declareBuiltin(new Builtin(Yield.name, Yield.type(), Yield.class));
    
    cxt.declareBuiltin(new Builtin(SimpleLog.name, SimpleLog.type(), SimpleLog.class));
  }
}
